﻿using B.S.DataBase.MyProject.Domain.基础设置;
using B.S.DataBase.MyProject.ErrorCode;
using B.S.DataBase.MyProject.Infrastructure;
using MediatR;
<<<<<<<< HEAD:MedicalPCTerminal.Write.API/Appcation/CommandHandlers/BasicSettingsCommandHandler/UpdateDiseaseIndicatorsCommandHandler.cs
using MedicalPCTerminal.Write.API.Appcation.Commands.BasicSettingsCommand;

namespace MedicalPCTerminal.Write.API.Appcation.CommandHandlers.BasicSettingsCommandHandler
========
using MedicalPCTerminal.Write.API.Appcation.Commands.基础设置;

namespace MedicalPCTerminal.Write.API.Appcation.CommandHandlers.基础设置
>>>>>>>> parent of fe317f5 (修改命名空间):MedicalPCTerminal.Write.API/Appcation/CommandHandlers/基础设置/UpdateDiseaseIndicatorsCommandHandler.cs
{
    /// <summary>
    /// 慢病指标-修改命令处理
    /// </summary>
    public class UpdateDiseaseIndicatorsCommandHandler : IRequestHandler<UpdateDiseaseIndicatorsCommand, APIResult<int>>
    {
        /// <summary>
        /// SqlSugar
        /// </summary>
        private readonly SqlSugarContext sqlSugar;
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="sqlSugar">SqlSugar</param>
        public UpdateDiseaseIndicatorsCommandHandler(SqlSugarContext sqlSugar)
        {
            this.sqlSugar = sqlSugar;
        }
        /// <summary>
        /// 处理
        /// </summary>
        /// <param name="request">请求</param>
        /// <param name="cancellationToken">取消</param>
        /// <returns>返回任务</returns>
        public Task<APIResult<int>> Handle(UpdateDiseaseIndicatorsCommand request, CancellationToken cancellationToken)
        {
            try
            {
                APIResult<int> result = new APIResult<int>();
                var list = sqlSugar.db.Queryable<DiseaseIndicators>().Where(x => x.IId == request.IId).First();
                list.IndicatorsName = request.IndicatorsName;
                list.IndicatorsId = request.IndicatorsId;
                list.IndicatorsCode = request.IndicatorsCode;
                list.IndicatorsValue = request.IndicatorsValue;
                var res = sqlSugar.db.Updateable(list).ExecuteCommand();
                if (res > 0)
                {
                    result.Code = APIEnum.修改成功;
                    result.Msg = APIEnum.修改成功.ToString();
                    result.data = res;
                }
                else
                {
                    result.Code = APIEnum.修改失败;
                    result.Msg = APIEnum.修改失败.ToString();
                    result.data = res;
                }

                return Task.FromResult(result);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
